import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class fortest {
    JFrame FileLoadingFrame;
    public static byte[] Testint2Bytes(int i){
        byte[] arr = new byte[4] ;
        arr[0] = (byte)i ;         //通过debug可以看到arr[0] = -23,也就是10010111
        arr[1] = (byte)(i >> 8) ;  //通过debug可以看到arr[1] = -18,也就是10010010
        arr[2] = (byte)(i >> 16) ; //通过debug可以看到arr[2] = 51, 也就是00110011
        arr[3] = (byte)(i >> 24) ; //通过debug可以看到arr[3] = 1,  也就是00000001
        return arr;
    }
    public static int Testbytes2Int(byte[] bytes){
        int i0= bytes[0] & 0xFF  ;
        int i1 = (bytes[1] & 0xFF) << 8 ;
        int i2 = (bytes[2] & 0xFF) << 16 ;
        int i3 = (bytes[3] & 0xFF) << 24 ;
        return i0 | i1 | i2 | i3 ;
    }
    public void showFileLoadingUI(int choose){
        FileLoadingFrame = new JFrame("Loading");
        FileLoadingFrame.setSize(150,150);
        FileLoadingFrame.setLocationRelativeTo(null);
        FileLoadingFrame.setDefaultCloseOperation(3);
        FileLoadingFrame.setLayout(new BorderLayout());

        String message;
        if(choose==1){
            message = "File is sending...";
        }else{
            message = "File is saving...";
        }
        JLabel jlb = new JLabel(message,SwingConstants.CENTER);
        FileLoadingFrame.add(jlb,BorderLayout.CENTER);
        FileLoadingFrame.setVisible(true);
    }
    public static void main(String[] args) throws Exception {
        new fortest().showFileLoadingUI(2);
    }
}
